package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_apply_order_info")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.ApplyOrderInfoMapper")
public class ApplyOrderInfoDO extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 机构主键id
     */
    @TableField(value = "org_id")
    private Long orgId;

    /**
     * 保函编号
     */
    @TableField(value = "guarantee_no")
    private String guaranteeNo;

    /**
     * 交易中心订单号
     */
    @TableField(value = "center_order_id")
    private String centerOrderId;

    /**
     * 受理投保订单号
     */
    @TableField(value = "accept_order_no")
    private String acceptOrderNo;

    /**
     * 申请开函订单号
     */
    @TableField(value = "apply_order_no")
    private String applyOrderNo;

    /**
     * 项目名称
     */
    @TableField(value = "project_name")
    private String projectName;

    /**
     * 合同/工程/标段名称
     */
    @TableField(value = "section_name")
    private String sectionName;

    /**
     * 申请企业名称/被担保企业
     */
    @TableField(value = "bid_customer_name")
    private String bidCustomerName;

    /**
     * 投标截止日期
     */
    @TableField(value = "bid_indate")
    private Date bidIndate;

    /**
     * 保函类型
     */
    @TableField(value = "guarantee_type")
    private String guaranteeType;

    /**
     * 保函品种
     */
    @TableField(value = "guarantee_category")
    private String guaranteeCategory;

    /**
     * 投标保证金/担保金额分
     */
    @TableField(value = "bid_bond")
    private Long bidBond;

    /**
     * 保费金额分
     */
    @TableField(value = "guarantee_fee")
    private Long guaranteeFee;

    /**
     * 开函机构名称
     */
    @TableField(value = "institution_name")
    private String institutionName;

    /**
     * 我的申请订单状态数字字典
     */
    @TableField(value = "status")
    private Integer status;

    /**
     * 出函时间
     */
    @TableField(value = "guarantee_time")
    private Date guaranteeTime;

    /**
     * 投保项目主键id
     */
    @TableField(value = "project_id")
    private Long projectId;

    /**
     * 投保客户主键id
     */
    @TableField(value = "bid_customer_id")
    private Long bidCustomerId;

    /**
     * 开函机构主键id
     */
    @TableField(value = "institution_id")
    private Long institutionId;

    /**
     * 交易中心主键id
     */
    @TableField(value = "center_id")
    private Long centerId;

    /**
     * 关联附件表主键id
     */
    @TableField(value = "attachment_id")
    private Long attachmentId;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 创建用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    /**
     * 备注说明
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 邀请码8位：配合交易中心推送信息关联
     */
    @TableField(value = "invite_code")
    private String inviteCode;

    /**
     * 保函序列号：共筑推送平台时返回
     */
    @TableField(value = "serial_num")
    private String serialNum;

    /**
     * 退款理赔状态    0待退款 1待复审 2已退款 3已拒绝 4已取消
     */
    @TableField(value = "refund_status")
    private Integer refundStatus;

    public ApplyOrderInfoVo buildVo() {
        return new ApplyOrderInfoVo(id, orgId, guaranteeNo, centerOrderId, acceptOrderNo, applyOrderNo, projectName, sectionName, bidCustomerName, bidIndate, guaranteeType, guaranteeCategory, bidBond, guaranteeFee, institutionName, status, guaranteeTime, projectId, bidCustomerId, institutionId, centerId, attachmentId, gmtCreate, gmtModified, userCreate, userModified, remark, inviteCode, serialNum, refundStatus);
    }

    public static ApplyOrderInfoDO of(ApplyOrderInfoVo vo) {
        return new ApplyOrderInfoDO(vo.getId(), vo.getOrgId(), vo.getGuaranteeNo(), vo.getCenterOrderId(), vo.getAcceptOrderNo(), vo.getApplyOrderNo(), vo.getProjectName(), vo.getSectionName(), vo.getBidCustomerName(), vo.getBidIndate(), vo.getGuaranteeType(), vo.getGuaranteeCategory(), vo.getBidBond(), vo.getGuaranteeFee(), vo.getInstitutionName(), vo.getStatus(), vo.getGuaranteeTime(), vo.getProjectId(), vo.getBidCustomerId(), vo.getInstitutionId(), vo.getCenterId(), vo.getAttachmentId(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified(), vo.getRemark(), vo.getInviteCode(), vo.getSerialNum(), vo.getRefundStatus());
    }
}
